package com.welkom.everydate.services.implementations;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.welkom.everydate.dao.RoleDao;
import com.welkom.everydate.domain.Role;
import com.welkom.everydate.services.interfaces.RoleService;
@Service
public class RoleServiceImpl implements RoleService {
	@Resource
	RoleDao roleDao;
	@Override
	public int getTotalCountByQueryCondition(Role role) {
		// TODO Auto-generated method stub
		return roleDao.getRoleTotalCountByCondition(role);
	}
	@Override
	public List<Role> getRolesByPage(Role role, int startIndex, int pageSize) {
		// TODO Auto-generated method stub
		return roleDao.queryRolesByCondtion(role, startIndex, pageSize);
	}
	@Override
	public void saveChangesToRole(Role role) {
		// TODO Auto-generated method stub
		roleDao.updateRole(role);
	}
	@Override
	public void addRole(Role role) {
		// TODO Auto-generated method stub
		roleDao.addRole(role);
	}
	@Override
	public void deleteRoleById(long roleId) {
		// TODO Auto-generated method stub
		roleDao.deleteRoleById(roleId);
	}
	@Override
	public Role getRoleById(long roleId){
		return roleDao.getRoleByRoleId(roleId);
	}
	@Override
	public List<Role> getRolesByUserId(long userId) {
		// TODO Auto-generated method stub
		return roleDao.getRolesByUserId(userId);
	}
	@Override
	public List<Role> getAllRoles(){
		return roleDao.getAllRoles();
	}
	@Override
	public void removeRolesByUserId(long userId) {
		// TODO Auto-generated method stub
		roleDao.removeUserRoleRelationsByUserId(userId);
		
	}
	@Override
	public void addRolesToUser(List<Role> roles, long userId) {
		// TODO Auto-generated method stub
		roleDao.insertUserRoleRelations(roles, userId);
		
	}

}
